//
//  WXPNotAuthHomeVC.m
//  MexicoLoan
//
//  Created by wxp on 2025/2/27.
//

#import "WXPNotAuthHomeVC.h"
#import "WXPNotAuthHomeMoneyView.h"
#import "WXPHomeCloundReportView.h"
#import "WXPFicoReport.h"

@interface WXPNotAuthHomeVC ()

@property (nonatomic, strong) WXPNavView  * navView;

@property (nonatomic, strong) UIView * viewHeader;
@property (nonatomic, strong) WXPNotAuthHomeMoneyView * viewTopMoney;
@property (nonatomic, strong) WXPHomeCloundReportView * cloundReportView;
@property (nonatomic, strong) WXPFicoReport * ficoReport;


@end

@implementation WXPNotAuthHomeVC

#pragma mark - lazy
- (WXPNavView *)navView{
    if (!_navView) {
        _navView = [WXPNavView new];
        _navView.leftTop = XY(0, 0);
        _navView.backBtn.hidden = true;
        [_navView resetViewWithTitle:[GlobalMethod getAppName]];
        [_navView addSubview:self.btnNotification];
    }
    return _navView;
}
- (UIButton *)btnNotification
{
    if (_btnNotification == nil) {
        _btnNotification = [UIButton  new];
        _btnNotification.widthHeight = XY(32, 44);
        _btnNotification.rightBottom = XY(self.navView.btnService.left-LEFT_MARDIN, self.navView.height);
        [_btnNotification setImage:[UIImage imageNamed:@"icon-home-notification"] forState:UIControlStateNormal];
        _btnNotification.hidden = true;
        WEAKSELF
        [_btnNotification setNoRepeatActionWithInterval:1 action:^(UIButton * _Nonnull button) {
            [NSObject clickFeedback];
            [weakSelf.btnNotification addClickAnimate];
            if(weakSelf.blockGetNotificationView){
                weakSelf.blockGetNotificationView();
            }
        }];
    }
    return  _btnNotification;
}
- (UIView *)viewHeader
{
    if (_viewHeader == nil) {
        _viewHeader = [UIView  new];
    }
    return  _viewHeader;
}
- (WXPNotAuthHomeMoneyView *)viewTopMoney
{
    if (_viewTopMoney == nil) {
        _viewTopMoney = [WXPNotAuthHomeMoneyView  new];
        WEAKSELF
        _viewTopMoney.blockJumpAuth = ^{
            [GlobalMethod hitPointWithPageName:KEY_Home action:KEY_Click extInfo:nil];
            // 界面跳转
            [GlobalMethod jumpToAuthWithAuthInfo:weakSelf.INFO_NAME];
        };
    }
    return  _viewTopMoney;
}
// CLOUND 信用报告
- (WXPHomeCloundReportView *)cloundReportView
{
    if (_cloundReportView == nil) {
        _cloundReportView = [WXPHomeCloundReportView  new];
    }
    return  _cloundReportView;
}
// FICO 信用报告
- (WXPFicoReport *)ficoReport
{
    if (_ficoReport == nil) {
        _ficoReport = [WXPFicoReport  new];
    }
    return  _ficoReport;
}
- (WXPBannerView *)bannerView
{
    if (_bannerView == nil) {
        _bannerView = [WXPBannerView  new];
    }
    return  _bannerView;
}

#pragma mark - viewDidLoad
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // 注册通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(authInfoStep:) name:LOCAL_AUTH_INFO_SETP object:nil];
    
    self.tableHeaderTopBg.backgroundColor = [UIColor clearColor];
    self.tableView.backgroundColor = [UIColor clearColor];
    self.viewBG.backgroundColor = [UIColor clearColor];
    self.view.backgroundColor = [UIColor clearColor];
    
    [self resetHeaderView];
}

#pragma mark - 通知
// 处理通知
- (void)authInfoStep:(NSNotification *)notification {
    NSDictionary *userInfo = notification.userInfo;
    NSString * value = userInfo[@"auth_type"];
    self.INFO_NAME = value;
}

#pragma mark - resetHeaderView
- (void)resetHeaderView{
    self.viewHeader = [UIView initWithViews:@[
        self.navView,
        [GlobalMethod getViewWithHeight:LEFT_MARDIN],
        self.viewTopMoney,
        self.isHideCloundun == true ? [UIView new] : self.cloundReportView,
        self.isHideFICO == true ? [UIView new] : self.ficoReport,
        isAry(self.bannerView.bannerList) ? self.bannerView : [UIView new],
    ]];
    self.tableView.tableHeaderView = self.viewHeader;
}


@end
